package com.Algorithm.HUAWEI.two20220303;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2022/03/18/22:39
 * @Description:
 * @Target:
 */
public class 单词倒排 {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String ss = in.readLine();


        boolean flag = false;
        ArrayList<String> list = new ArrayList<>();
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < ss.length(); i++) {
            if (ss.charAt(i)>='a'&&ss.charAt(i)<='z'||ss.charAt(i)>='A'&&ss.charAt(i)<='Z'){
                stringBuffer.append(ss.charAt(i));
                flag = false;
            }else if (flag==false&&ss.charAt(i)<'a'||ss.charAt(i)>'z'||ss.charAt(i)<'A'||ss.charAt(i)>'Z'){
                list.add((stringBuffer.toString()));
                list.add(" ");
                stringBuffer.delete(0,stringBuffer.length());
                flag = true;
            }
        }
        if (stringBuffer.length()>0){
            list.add((stringBuffer.toString()));
        }

        for (int i = list.size()-1; i >= 0; i--) {
            if (i==list.size()&&list.get(i).equals(" ")){

            }else {
                System.out.print(list.get(i));
            }
        }

    }
}
